new Vue({
    el: '#cele',
    data: {
        time:'',
        flag:'',
        adminLists:[],
        form: {
            name: '',
            Degree: '',
            Politics_status: '',
            Is_leader: '',
            Is_normal: '',
            Is_driver: '',
            Is_contact: '',
            Degree: '',
            Degree: '',
            date1: '',
            date2: '',
            Nation:'',
            delivery: false,
        },
        flag1:'',
        flag2:'',
        FireManInfoModel:{},
        UserRoleRelationModel:{},
        dataTime:''
    },
    mounted() {
        this.restaurants = this.loadAll();
        this.FireManInfoModel = $.parseJSON(localStorage.getItem('msg'));
        console.log(this.FireManInfoModel.Fire_brigade_num)
        this.UserRoleRelationModel = $.parseJSON(localStorage.getItem('item'));
        var _Vue = this
        setInterval(function () {
            var time = new Date();
            var y = time.getFullYear();
            var m = time.getMonth() + 1;
            var d = time.getDate();
            var h = time.getHours();
            var mm = time.getMinutes();
            var s = time.getSeconds();
            _Vue.time = y + '年' + _Vue.add0(m) + '月' + _Vue.add0(d) + '日  ' + _Vue.add0(h) + ':' + _Vue.add0(mm) + ':' + _Vue.add0(s);

        }, 1000)

        $('.main-left-bj ul li a').click(function () {
            //console.log(this)
            $(this).find('span').toggleClass('glyphicon-plus glyphicon-minus yellow-text')
        });
        this.ajaxProceedFires()
    },
    computed:{




    },
    methods:{

        //弹窗
        goin(item){
            this.flag='1';
            this.flag1='1'
            this.flag2=''
            this.form=item
        },
        quxiao(){
            debugger
            this.flag=false
        },
        /*模拟数据*/
        querySearch(queryString, cb) {
            var restaurants = this.restaurants;
            var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
            // 调用 callback 返回建议列表的数据
            cb(results);
        },
        createFilter(queryString) {
            return (restaurant) => {
                debugger
                return (restaurant.value.indexOf(queryString) === 0);
            };
        },
        handleSelect(item) {
            console.log(item);
        },
        loadAll() {
            return [
                {value:"汉族"},
                {value:"蒙古族"},
                {value:"回族"},
                {value:"藏族"},
                {value:"维吾尔族"},
                {value:"苗族"},
                {value:"彝族"},
                {value:"壮族"},
                {value:"布依族"},
                {value:"朝鲜族"},
                {value:"满族"},
                {value:"侗族"},
                {value:"瑶族"},
                {value:"白族"},
                {value:"土家族"},
                {value:"哈尼族"},
                {value:"哈萨克族"},
                {value:"傣族"},
                {value:"黎族"},
                {value:"傈僳族"},
                {value:"佤族"},
                {value:"畲族"},
                {value:"高山族"},
                {value:"拉祜族"},
                {value:"水族"},
                {value:"东乡族"},
                {value:"纳西族"},
                {value:"景颇族"},
                {value:"柯尔克孜族"},{value:"土族"},
                {value:"达斡尔族"},
                {value:"仫佬族"},
                {value:"羌族"},
                {value:"布朗族"},
                {value:"撒拉族"},
                {value:"毛难族"},
                {value:"仡佬族"},
                {value:"锡伯族"},{value:"阿昌族"},
                {value:"普米族"},
                {value:"塔吉克族"},
                {value:"怒族"},
                {value:"乌孜别克族"},
                {value:"俄罗斯族"},
                {value:"鄂温克族"},
                {value:"崩龙族"},
                {value:"保安族"},
                {value:"裕固族"},
                {value:"京族"},
                {value:"塔塔尔族"},
                {value:"独龙族"},
                {value:"鄂伦春族"},
                {value:"赫哲族"},
                {value:"门巴族"},
                {value:"珞巴族"},
                {value:"基诺族"}
            ];
        },
        ajaxProceedFires(){
            var Vue = this;
            //console.log(this.FireManInfoModel)
            $.ajax({
                type: 'post',
                url: Url+'FireStationApi/GetStationByBrigadeNumber',
                data: JSON.stringify({ BrigadeNumber: Vue.FireManInfoModel.Fire_brigade_num}),//中队编号
                dataType:'json',
                contentType: 'application/json',
                success: function (msg) {
                    debugger
                    //console.log(this.FireManInfoModel)
                    console.log(msg)
                    Vue.adminLists= msg.data

                }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                }
            });
        },
        updata(){
            var Vue = this;
            $.ajax({
                type: 'post',
                url: Url+'FireStationApi/UpdateStationAndManager',
                data: JSON.stringify(this.form),//中队编号
                dataType:'json',
                contentType: 'application/json',
                success: function (msg) {
                    if(msg.state==1){
                        Vue.$message.success("更新成功");
                        Vue.flag = ''
                    }else {
                        Vue.$message.error('更新失败')
                    }

                }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                }
            });
        },
        newValpeople(){
            this.form=[]
            this.flag='1'
            this.flag2='1'
            this.flag1=''
        },
        InsertStationAndManager(){
            var Vue = this
            $.ajax({
                type: 'post',
                url: Url+'FireStationApi/InsertStationAndManager',
                data: JSON.stringify({
                    Contact1: "321",
                    Contact2: "321",
                    Manager_name: "213",
                    Station_name: "321",
                    Station_number:'',
                    Address:'',
                    Fire_brigade:'',
                    Gaode_coordinate:'',
                    Manager_number:'',
                    If_main:'1',
                    Belong_area_number:'',
                    Belong_area_name:''

                }),//中队编号
                dataType:'json',
                contentType: 'application/json',
                success: function (msg) {
                    debugger
                    if(msg.state==1){
                        Vue.$message.success("新增成功");
                        Vue.flag = ''
                    }else {
                        Vue.$message.error('新增失败')
                    }
                }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                }
            });
        },

        deldata(item){
            var Vue = this
            $.ajax({
                type: 'post',
                url: Url+'FireStationApi/DeleteStation',
                data: JSON.stringify(item),//中队编号
                dataType:'json',
                contentType: 'application/json',
                success: function (msg) {
                    debugger
                    if(msg.state==1){
                        Vue.$message.success("新增成功");
                        Vue.flag = ''
                    }else {
                        Vue.$message.error('新增失败')
                    }
                }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                }
            });
        },
        dowm(index){

        },
        add0(m){
            return m<10?'0'+m:m
        },
        Quit(){
            $.cookie('token', '',{ expires: -1 ,path: '/' });
            window.location.href='../login.html'
        }
    }

})
